<script setup>
import { GetPlantService } from '@/api/clothrequest'
import { ref } from 'vue'
import { useParms } from '@/stores'
defineProps({
  modelValue: {
    type: [Number, String]
  },
  width: {
    type: String
  }
})
const useparams = useParms()
const emit = defineEmits(['update:modelValue'])
const plantList = ref([])
const getPlantList = async () => {
  const res = await GetPlantService()
  plantList.value = res.data.data
}
const changeFactory = ($event) => {
  useparams.params.factoryId = $event
  console.log(useparams.params.factoryId)
}
getPlantList()
</script>

<template>
  <!-- label 展示给用户看的，value 收集起来提交给后台的 -->
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
    :style="{ width }"
    @change="changeFactory($event)"
    @click="getPlantList()"
  >
    <el-option
      v-for="channel in plantList"
      :key="channel.id"
      :label="channel.factoryName"
      :value="channel.factoryId"
    ></el-option>
  </el-select>
</template>
